草庐IT

ASP.NET Web Forms - 维持 ViewState

全部标签

c# - ASP.NET MVC 体系结构 : ViewModel by composition, 继承还是重复?

我正在使用ASP.NETMVC3和EntityFramework4.1CodeFirst。假设我有一个User实体:publicclassUser{publicintId{get;set;}publicstringName{get;set;}publicstringEmail{get;set;}publicstringPassword{get;set;}}在我的UserController中编辑它时,我想添加一个PasswordConfirmation字段并验证PasswordConfirmation==Password1。按组成我的第一次尝试是:publicclassEditUser

c# - ASP.NET MVC 体系结构 : ViewModel by composition, 继承还是重复?

我正在使用ASP.NETMVC3和EntityFramework4.1CodeFirst。假设我有一个User实体:publicclassUser{publicintId{get;set;}publicstringName{get;set;}publicstringEmail{get;set;}publicstringPassword{get;set;}}在我的UserController中编辑它时,我想添加一个PasswordConfirmation字段并验证PasswordConfirmation==Password1。按组成我的第一次尝试是:publicclassEditUser

c# - 我应该使用 AddMvc 还是 AddMvcCore 进行 ASP.NET Core MVC 开发?

我正在看书学习ASP.NETCoreMVC,问题代码片段如下://CHAPTER4-ESSENTIALC#FEATURESnamespaceLanguageFeatures{publicclassStartup{publicvoidConfigureServices(IServiceCollectionservices){services.AddMvc();}//etc.因为这本书是关于ASP.NETCoreMVC而不是ASP.NETMVC,我想我必须使用AddMvcCore()而不是AddMvc()如下:publicvoidConfigureServices(IServiceColl

c# - 我应该使用 AddMvc 还是 AddMvcCore 进行 ASP.NET Core MVC 开发?

我正在看书学习ASP.NETCoreMVC,问题代码片段如下://CHAPTER4-ESSENTIALC#FEATURESnamespaceLanguageFeatures{publicclassStartup{publicvoidConfigureServices(IServiceCollectionservices){services.AddMvc();}//etc.因为这本书是关于ASP.NETCoreMVC而不是ASP.NETMVC,我想我必须使用AddMvcCore()而不是AddMvc()如下:publicvoidConfigureServices(IServiceColl

c# - 何时以及为何在 asp.net mvc 2 中使用 TryUpdateModel?

我似乎无法找到一个基本的代码示例来了解TryUpdateModel的工作原理?你什么时候使用它,为什么? 最佳答案 您可以使用此方法通过给定Controller更新支持特定View的模型。例如,如果我有一个显示Foo对象的View,该对象的属性Bar由文本框填充,我可以调用Controller上的方法Save()并调用TryUpdateModel来尝试更新Foo。publicclassFoo{publicstringBar{get;set;}}//...inthecontrollerpublicActionResultSave(){

c# - 何时以及为何在 asp.net mvc 2 中使用 TryUpdateModel?

我似乎无法找到一个基本的代码示例来了解TryUpdateModel的工作原理?你什么时候使用它,为什么? 最佳答案 您可以使用此方法通过给定Controller更新支持特定View的模型。例如,如果我有一个显示Foo对象的View,该对象的属性Bar由文本框填充,我可以调用Controller上的方法Save()并调用TryUpdateModel来尝试更新Foo。publicclassFoo{publicstringBar{get;set;}}//...inthecontrollerpublicActionResultSave(){

c# - ASP.NET MVC - URL 的提取参数

我正在尝试提取我的URL的参数,就像这样。/Administration/Customer/Edit/1摘录:1/Administration/Product/Edit/18?allowed=true摘录:18?allowed=true/Administration/Product/Create?allowed=true摘录:?allowed=true有人可以帮忙吗?谢谢! 最佳答案 更新RouteData.Values["id"]+Request.Url.Query将匹配你所有的例子目前还不完全清楚您要实现的目标。MVC通过模型绑

c# - ASP.NET MVC - URL 的提取参数

我正在尝试提取我的URL的参数,就像这样。/Administration/Customer/Edit/1摘录:1/Administration/Product/Edit/18?allowed=true摘录:18?allowed=true/Administration/Product/Create?allowed=true摘录:?allowed=true有人可以帮忙吗?谢谢! 最佳答案 更新RouteData.Values["id"]+Request.Url.Query将匹配你所有的例子目前还不完全清楚您要实现的目标。MVC通过模型绑

c# - 如何使用 asp.net mvc 3 和 c# 清除 cookie?

好的,所以我真的认为我这样做是对的,但是cookie没有被清除。Session.Clear();HttpCookiec=Request.Cookies["MyCookie"];if(c!=null){c=newHttpCookie("MyCookie");c["AT"]=null;c.Expires=DateTime.Now.AddDays(-1);Request.Cookies.Add(c);}returnRedirectToAction("Index","Home");当重定向发生时,它会再次找到cookie并继续前进,就好像我从未注销过一样。有什么想法吗?

c# - 如何使用 asp.net mvc 3 和 c# 清除 cookie?

好的,所以我真的认为我这样做是对的,但是cookie没有被清除。Session.Clear();HttpCookiec=Request.Cookies["MyCookie"];if(c!=null){c=newHttpCookie("MyCookie");c["AT"]=null;c.Expires=DateTime.Now.AddDays(-1);Request.Cookies.Add(c);}returnRedirectToAction("Index","Home");当重定向发生时,它会再次找到cookie并继续前进,就好像我从未注销过一样。有什么想法吗?